<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="/layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">Questão</f:facet>

		
        <s:decorate id="questao" template="/layout/display.xhtml">
            <ui:define name="label">Questão</ui:define>
            <h:outputText value="#{questaoHome.instance.questao}"/>
        </s:decorate>

        <s:decorate id="tipoQuestao" template="/layout/display.xhtml">
            <ui:define name="label">Tipo da Questao</ui:define>
            <h:outputText value="#{questaoHome.instance.tipoQuestao}"/>
        </s:decorate>
        
        <s:decorate id="acertos" template="/layout/display.xhtml">
            <ui:define name="label">Acertos</ui:define>
            <h:outputText value="#{questaoHome.instance.acertos}"/>
        </s:decorate>

        <s:decorate id="erros" template="/layout/display.xhtml">
            <ui:define name="label">Erros</ui:define>
            <h:outputText value="#{questaoHome.instance.erros}"/>
        </s:decorate>

        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/resources/QuestaoEdit.xhtml"
                    id="edit"
                 value="Editar"
              rendered="#{s:hasRole('Subgrupo') or usuario.id eq questaoHome.instance.questionario.usuario.id}"/>

        <s:button view="/resources/#{empty questaoFrom ? 'QuestaoList' : questaoFrom}.xhtml"
                    id="done"
                 value="Concluído"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Questionário</h:panelGroup>
        </f:facet>
    <div class="association" id="questionarioParent">

        <h:outputText value="Não existe Questionário atrelado a esta Questão."
                   rendered="#{questaoHome.instance.questionario == null}"/>

        <rich:dataTable var="_questionario"
                   value="#{questaoHome.instance.questionario}"
                rendered="#{questaoHome.instance.questionario != null}"
              rowClasses="odd,even"
                      id="questionarioTable">
            <h:column>
                <f:facet name="header">Nome</f:facet>
                <h:outputText value="#{_questionario.nome}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Nível</f:facet>
                <h:outputText value="#{_questionario.nivel}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Cliques</f:facet>
                <h:outputText value="#{_questionario.cliques}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Data de Cadastro</f:facet>
                <h:outputText value="#{_questionario.dataCadastro.time}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Usuário</f:facet>
                <h:outputText value="#{_questionario.usuario.nome}"/>
            </h:column>
            <rich:column styleClass="action" style="text-align: center;">
                <f:facet name="header">Opções</f:facet>
                <s:link id="viewquestionario"
                     value="Ver"
                      view="/resources/Questionario.xhtml">
                    <f:param name="questionarioId"
                           value="#{_questionario.id}"/>
                </s:link>
            </rich:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Resposta</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="respostaChildren">

        <h:outputText value="Não existe Resposta cadastrada."
                   rendered="#{empty questaoHome.resposta}"/>

        <rich:dataTable value="#{questaoHome.resposta}"
                       var="_resposta"
                  rendered="#{not empty questaoHome.resposta}"
                rowClasses="odd,even"
                        id="respostaTable">
            <rich:column sortBy="#{_resposta.resposta}">
                <f:facet name="header">Enunciado</f:facet>
                <h:outputText value="#{_resposta.resposta}"/>
            </rich:column>
            <rich:column sortBy="#{_resposta.cliques}">
                <f:facet name="header">Cliques</f:facet>
                <h:outputText value="#{_resposta.cliques}"/>
            </rich:column>
            <rich:column sortBy="#{_resposta.correta}">
                <f:facet name="header">Correta</f:facet>
                <h:outputText value="#{_resposta.correta}"/>
            </rich:column>
            <rich:column style="text-align: center;">
                <f:facet name="header">Opções</f:facet>
                <s:link id="selectresposta"
                     value="Selecionar"
                      view="/resources/Resposta.xhtml">
                    <f:param name="respostaId"
                            value="#{_resposta.id}"/>
                    <f:param name="respostaFrom" value="Questao"/>
                </s:link>
            </rich:column>
        </rich:dataTable>

    </h:form>

    <div class="actionButtons">
        <s:button
               value="Cadastrar Resposta"
                view="/resources/RespostaEdit.xhtml"
            rendered="#{s:hasRole('Subgrupo') or permissao.minhaQuestao}">
            <f:param name="questaoId"
                    value="#{questaoHome.instance.id}"/>
            <f:param name="respostaFrom" value="Questao"/>
        </s:button>
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
